<?php

$doc = $_POST['doc'];
$name = $_POST['name'];


include dirname(__FILE__) . '/../classes/Connection.class.php';
$objConn = new CONNECTION();
if ((!empty($doc)) && (empty($name))) {
    $sql = "select * from Clientes where cpf=$doc";
} else if (!empty($name) && (empty($doc))) {
    $sql = "select * from Clientes where name=$name";
} else if ((!empty($name)) && (!empty($doc))) {
    $sql = "select * from Clientes where cpf=$doc and name=$name";
}
else
    $sql = "select * from Clientes";
$result = $objConn->search($sql);


if ($result == true) {


    for ($i = 0; $i < count($result); $i++) {

        echo"Nome:" . $result[$i]['name'] . " | Phone:" . $result[$i]['fone'] . " | Nascimento:" . $result[$i]['birth'] . " | Cadastro:" . $result[$i]['cadastre'] . " | Sexo:" . $result[$i]['sexo'];
        echo "<br>";
    }
} else {
    echo 'Nenhum registro encontrado';
}
?>

